<div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.shortcuts</span> <span class="kn">import</span> <span class="n">get_object_or_404</span>
<span class="kn">from</span> <span class="nn">django.http</span> <span class="kn">import</span> <span class="n">HttpResponse</span><span class="p">,</span> <span class="n">HttpResponseRedirect</span>
<span class="kn">from</span> <span class="nn">django.template.defaultfilters</span> <span class="kn">import</span> <span class="n">slugify</span>
<span class="kn">from</span> <span class="nn">django.contrib.auth.decorators</span> <span class="kn">import</span> <span class="n">login_required</span>
<span class="kn">from</span> <span class="nn">django.conf</span> <span class="kn">import</span> <span class="n">settings</span>
<span class="kn">from</span> <span class="nn">django.core.paginator</span> <span class="kn">import</span> <span class="n">Paginator</span><span class="p">,</span> <span class="n">InvalidPage</span><span class="p">,</span> <span class="n">EmptyPage</span>

<span class="kn">from</span> <span class="nn">obviews.views</span> <span class="kn">import</span> <span class="n">View</span><span class="p">,</span> <span class="n">FormView</span><span class="p">,</span> <span class="n">AjaxFormView</span><span class="p">,</span> <span class="n">CutResponse</span>
<span class="kn">from</span> <span class="nn">obviews.fallbacks</span> <span class="kn">import</span> <span class="n">HttpResponseBadRequest</span>
<span class="kn">from</span> <span class="nn">polls.published_manager</span> <span class="kn">import</span> <span class="n">STATE_DEFAULT</span><span class="p">,</span> <span class="n">STATE_PUBLISHED</span>
<span class="kn">from</span> <span class="nn">polls.models</span> <span class="kn">import</span> <span class="n">Poll</span><span class="p">,</span> <span class="n">Vote</span><span class="p">,</span> <span class="n">Choice</span>
<span class="kn">from</span> <span class="nn">polls.forms</span> <span class="kn">import</span> <span class="o">*</span>

<span class="c"># POLLS #########################################################</span>
<span class="k">class</span> <span class="nc">PaginatedPollView</span><span class="p">(</span><span class="n">PaginatedView</span><span class="p">):</span>
    <span class="n">template_name</span> <span class="o">=</span> <span class="s">&quot;polls/poll_list.html&quot;</span>
    <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;base_url&quot;</span><span class="p">:</span> <span class="s">&quot;poll_list&quot;</span><span class="p">}</span>
    
<span class="k">class</span> <span class="nc">PostedView</span><span class="p">(</span><span class="n">View</span><span class="p">):</span>
    <span class="n">template_name</span> <span class="o">=</span> <span class="s">&quot;polls/poll_posted.html&quot;</span>
    <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;p&quot;</span><span class="p">:</span> <span class="s">&quot;posted&quot;</span><span class="p">}</span>


<span class="c"># CHOICES ############################################################</span>
<span class="c"># VOTES ##############################################################</span>

<span class="k">class</span> <span class="nc">PaginatedVoteView</span><span class="p">(</span><span class="n">PaginatedView</span><span class="p">):</span>
    <span class="n">template_name</span> <span class="o">=</span> <span class="s">&quot;polls/vote_list.html&quot;</span>
    <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;per_page&quot;</span><span class="p">:</span> <span class="mi">50</span><span class="p">,</span>
                <span class="s">&quot;base_url&quot;</span><span class="p">:</span> <span class="s">&quot;votes_ordered&quot;</span><span class="p">,</span>
                <span class="s">&quot;order_by&quot;</span><span class="p">:</span> <span class="s">&quot;choice&quot;</span><span class="p">,}</span>        
</pre></div>
